package com.lmh.bean;

public enum HttpStatusCode {
    OK("0"),
    NOT_FOUND("404"),
    INTERNAL_SERVER_ERROR("500"),
    BAD_REQUEST("400");

    private final String code;

    // 枚举的构造函数默认是私有的
    HttpStatusCode(String code) {
        this.code = code;
    }

    // 获取HTTP状态码的方法
    public String getCode() {
        return code;
    }

    // 根据状态码获取枚举实例的方法（可选）
    public static HttpStatusCode fromCode(String code) {
        for (HttpStatusCode statusCode : HttpStatusCode.values()) {
            if (statusCode.getCode() == code) {
                return statusCode;
            }
        }
        throw new IllegalArgumentException("No matching HTTP status code found");
    }
}